﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AFCEPF.BankApplication.BLL
{
    /// <summary>
    /// IVisitor implementor that will withdraw 
    /// the monthly fees on each Account type.
    /// </summary>
    public class MonthlyFeesVisitor  : IVisitor
    {

        #region -- IVisitor Members --

        /// <summary>
        /// Visits the specified visitable and
        /// withdraws the monthly fees on each account 
        /// type.
        /// </summary>
        /// <param name="visitable">The visitable.</param>
        public void Visit(IVisitable visitable)
        {
            AccountBase target;
            
            if (visitable is SimpleAccount)
            {
                // let's cast..
                target = visitable as SimpleAccount;
                target.Withdraw(1);
            }
            else if (visitable is SilverAccount)
            {
                target = visitable as SilverAccount;
                target.Withdraw(2);
            }
            else if (visitable is GoldAccount)
            {
                target = visitable as GoldAccount;
                target.Withdraw(3);
            }
            //else
            //{
            //    throw new Exception("L'objet doit être de type AccountBase ou dérivé");
            //}
        }

        #endregion
    }
}
